package com.dm_solution.powerlineswitch;

import android.os.Bundle;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.view.Display;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Surface;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

public class MainActivity extends BaseActivity{

	
	private void addButtons()
	{

		ImageButton button2 = (ImageButton) findViewById(R.id.imageButton1);
		isGooglePlayServicesAvailable(getApplicationContext());
		
		button2.setOnClickListener(new OnClickListener() {            
			public void onClick(View v)
			{
				String notificationService = Context.NOTIFICATION_SERVICE;

				NotificationManager notificationManager = 

		                    (NotificationManager) getSystemService(notificationService);


		Notification notification = new Notification(R.drawable.ic_launcher, 

		            "Hello Notification!", System.currentTimeMillis());
		notification.defaults |= Notification.DEFAULT_SOUND;

		notification.defaults |= Notification.DEFAULT_VIBRATE;



		Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);

		PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0,

		                                notificationIntent, 0);

		notification.setLatestEventInfo(getApplicationContext(), "Notification Title", 

		                                "Notification Text", contentIntent);

		notificationManager.notify(1, notification);
			}
			});



		Button button1 = (Button) findViewById(R.id.button1);
		button1.setOnClickListener(new OnClickListener() {            
			public void onClick(View v)
			{
		        Intent myIntent = new Intent(getApplicationContext(), MainActivity2.class);
				EditText editText1 = (EditText) findViewById(R.id.editText1);
		        myIntent.putExtra("MyString", editText1.getText().toString()); 
		        
				startActivity(myIntent);

				Display display = ((WindowManager) 
		                getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
		        if ((display.getRotation() == Surface.ROTATION_0) || 
		            (display.getRotation() == Surface.ROTATION_180)) {
		            overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out);
		        } else if ((display.getRotation() == Surface.ROTATION_90) ||
		                   (display.getRotation() == Surface.ROTATION_270)) {
		            overridePendingTransition(R.anim.slide_up, R.anim.slide_down);
		        }
		        
				MyApplication myApp = (MyApplication) getApplication();
				editText1 = (EditText) findViewById(R.id.editText1);
				myApp.setMyApplicationString(editText1.getText().toString());
			}
			});
		
		Button button3 = (Button) findViewById(R.id.button2);
		button3.setOnClickListener(new OnClickListener() {            
			public void onClick(View v)
			{
		        Intent myIntent = new Intent(getApplicationContext(), MainActivity3.class);
				startActivity(myIntent);
			}
			});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
	    MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.options_menu, menu);
	    return true;
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		addButtons();




	}


}
